package com.lagou.demo;

import com.lagou.http.HttpServlet;
import com.lagou.http.Request;
import com.lagou.http.Response;
import com.lagou.util.HttpProtocolUtil;

import java.io.IOException;

/**
 * @author stevejson
 */
public class MyServlet extends HttpServlet {
    @Override
    public void doGet(Request request, Response response) {
        String data = "<h1>hallo servlet get demo02</h1>";
        try {
            response.outPut(HttpProtocolUtil.getHttpHeader200(data.getBytes().length)+data);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void doPost(Request request, Response response) {
        String data = "<h1>hallo servlet post </h1>";
        try {
            response.outPut(HttpProtocolUtil.getHttpHeader200(data.getBytes().length)+data);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void init() throws Exception {

    }

    @Override
    public void destroy() throws Exception {

    }
}
